package com.yun.zf.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yun.zf.common.admin.domain.SysRoleMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 角色与菜单关联表 数据层
 * 
 * @author ruoyi
 */
@Mapper
public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu>
{
    /**
     * 查询菜单使用数量
     *
     * @param menuId 菜单ID
     * @return 结果
     */
    @Select("<script>" +
            "   select count(1) from sys_role_menu where menu_id = #{menuId}   " +
            "</script>")
    public int checkMenuExistRole(Long menuId);

    /**
     * 通过角色ID删除角色和菜单关联
     *
     * @param roleId 角色ID
     * @return 结果
     */
    @Delete("<script>" +
            " delete from sys_role_menu where role_id=#{roleId}" +
            "</script>")
    public void deleteRoleMenuByRoleId(Long roleId);


}
